package cn.kgc.web.controller;
/*
 * @Author wangchangsheng
 * @Date 2023/5/26
 * @PackageName:cn.kgc.controller
 * @ClassName: CarServiceController
 * @Description: TODO
 */


import cn.kgc.bean.pojo.CarService;
import cn.kgc.bean.pojo.CarServiceRecord;
import cn.kgc.bean.vo.Result;
import cn.kgc.service.CarServiceRecordService;
import cn.kgc.service.CarServiceService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/api/service")
public class CarServiceController {

    @Resource
    CarServiceService carServiceService;

    @Resource
    CarServiceRecordService carServiceRecordService;


    @GetMapping("/info")
    public Result info(@RequestParam String number){
        List<CarService> list = carServiceService.info(number);
        return Result.success(list);
    }

    @PostMapping("/verification")
    public Result verification(@RequestBody CarService carService){

        boolean flag = carServiceService.verification(carService);
        if (flag){
            return Result.success(flag);
        }else {
          return  Result.failure();
        }
    }

    @PostMapping("/addRecord")
    public Result addRecord(@RequestBody CarServiceRecord carServiceRecord){

        boolean flag = carServiceRecordService.addRecord(carServiceRecord);
        if (flag){
            return Result.success(flag);
        }else {
            return  Result.failure();
        }
    }
}
